package com.xbongbong.saas.domain.entity;

import com.xbongbong.paas.toolbox.util.Arith;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class BatchFlowBillUpdateEntity {

    //用于批量更新流水
    private String batchKey;
    //总库存
    private Double stock;
    //总成本
    private Double cost;
    //开始时间
    private Long startTime;
    //结束时间
    private Long endTime;
    //更新时间
    private Long updateTime;
    //左区间id
    private Long startId;
    //右区间id
    private Long endId;
    //右区间id
    private Long refId;

    public BatchFlowBillUpdateEntity(String batchKey, Double stock, Double cost, Long startTime, Long updateTime, Long refId) {
        this.batchKey = batchKey;
        this.stock = stock;
        this.cost = cost;
        this.startTime = startTime;
        this.updateTime = updateTime;
        this.refId = refId;
    }

    /**
     * 更新库存、成本
     * @param amendNum 库存
     * @param amendCost 单位成本
     */
    public void updateStock(Double amendNum, Double amendCost) {
        this.stock = Arith.add(this.stock,amendNum);
        this.cost = Arith.add(this.cost,Arith.mul(amendNum,amendCost));
    }

}
